{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"authorship_tag":"ABX9TyNvrr0FEuDOxYNjkirEJTkE"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","execution_count":null,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"n8GSTAyK1uH_","executionInfo":{"status":"ok","timestamp":1719881162799,"user_tz":-480,"elapsed":37868,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"4063eca8-665c-4889-945b-96b44291946f","collapsed":true},"outputs":[{"output_type":"stream","name":"stdout","text":["Collecting langchain\n","  Downloading langchain-0.2.6-py3-none-any.whl (975 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m975.5/975.5 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hCollecting langchain_community\n","  Downloading langchain_community-0.2.6-py3-none-any.whl (2.2 MB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.2/2.2 MB\u001b[0m \u001b[31m13.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hCollecting faiss-gpu\n","  Downloading faiss_gpu-1.7.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (85.5 MB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m85.5/85.5 MB\u001b[0m \u001b[31m5.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hCollecting langgraph\n","  Downloading langgraph-0.1.5-py3-none-any.whl (88 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m89.0/89.0 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hRequirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from langchain) (6.0.1)\n","Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.0.31)\n","Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from langchain) (3.9.5)\n","Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /usr/local/lib/python3.10/dist-packages (from langchain) (4.0.3)\n","Collecting langchain-core<0.3.0,>=0.2.10 (from langchain)\n","  Downloading langchain_core-0.2.10-py3-none-any.whl (332 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m332.8/332.8 kB\u001b[0m \u001b[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hCollecting langchain-text-splitters<0.3.0,>=0.2.0 (from langchain)\n","  Downloading langchain_text_splitters-0.2.2-py3-none-any.whl (25 kB)\n","Collecting langsmith<0.2.0,>=0.1.17 (from langchain)\n","  Downloading langsmith-0.1.82-py3-none-any.whl (127 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m127.4/127.4 kB\u001b[0m \u001b[31m7.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hRequirement already satisfied: numpy<2,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain) (1.25.2)\n","Requirement already satisfied: pydantic<3,>=1 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.7.4)\n","Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from langchain) (2.31.0)\n","Requirement already satisfied: tenacity!=8.4.0,<9.0.0,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain) (8.4.2)\n","Collecting dataclasses-json<0.7,>=0.5.7 (from langchain_community)\n","  Downloading dataclasses_json-0.6.7-py3-none-any.whl (28 kB)\n","Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n","Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (23.2.0)\n","Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.4.1)\n","Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.5)\n","Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.4)\n","Collecting marshmallow<4.0.0,>=3.18.0 (from dataclasses-json<0.7,>=0.5.7->langchain_community)\n","  Downloading marshmallow-3.21.3-py3-none-any.whl (49 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.2/49.2 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hCollecting typing-inspect<1,>=0.4.0 (from dataclasses-json<0.7,>=0.5.7->langchain_community)\n","  Downloading typing_inspect-0.9.0-py3-none-any.whl (8.8 kB)\n","Collecting jsonpatch<2.0,>=1.33 (from langchain-core<0.3.0,>=0.2.10->langchain)\n","  Downloading jsonpatch-1.33-py2.py3-none-any.whl (12 kB)\n","Requirement already satisfied: packaging<25,>=23.2 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.3.0,>=0.2.10->langchain) (24.1)\n","Collecting orjson<4.0.0,>=3.9.14 (from langsmith<0.2.0,>=0.1.17->langchain)\n","  Downloading orjson-3.10.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (144 kB)\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m145.0/145.0 kB\u001b[0m \u001b[31m2.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25hRequirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (0.7.0)\n","Requirement already satisfied: pydantic-core==2.18.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (2.18.4)\n","Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1->langchain) (4.12.2)\n","Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (3.3.2)\n","Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (3.7)\n","Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (2.0.7)\n","Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain) (2024.6.2)\n","Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->langchain) (3.0.3)\n","Collecting jsonpointer>=1.9 (from jsonpatch<2.0,>=1.33->langchain-core<0.3.0,>=0.2.10->langchain)\n","  Downloading jsonpointer-3.0.0-py2.py3-none-any.whl (7.6 kB)\n","Collecting mypy-extensions>=0.3.0 (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain_community)\n","  Downloading mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)\n","Installing collected packages: faiss-gpu, orjson, mypy-extensions, marshmallow, jsonpointer, typing-inspect, jsonpatch, langsmith, dataclasses-json, langchain-core, langgraph, langchain-text-splitters, langchain, langchain_community\n","Successfully installed dataclasses-json-0.6.7 faiss-gpu-1.7.2 jsonpatch-1.33 jsonpointer-3.0.0 langchain-0.2.6 langchain-core-0.2.10 langchain-text-splitters-0.2.2 langchain_community-0.2.6 langgraph-0.1.5 langsmith-0.1.82 marshmallow-3.21.3 mypy-extensions-1.0.0 orjson-3.10.5 typing-inspect-0.9.0\n"]}],"source":["pip install langchain langchain_community faiss-gpu langgraph"]},{"cell_type":"code","source":["pip install -qU langchain-openai"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"collapsed":true,"id":"H5YVkSQK351t","executionInfo":{"status":"ok","timestamp":1719881187555,"user_tz":-480,"elapsed":10152,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"0fe865f9-dfc8-4f4a-9c50-379d4e47968a"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.9/45.9 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m327.5/327.5 kB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m8.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.6/75.6 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m77.9/77.9 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m6.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25h"]}]},{"cell_type":"code","source":["import os\n","from google.colab import userdata\n","os.environ[\"OPENAI_API_KEY\"] = userdata.get('MOON_API_KEY')\n","os.environ[\"OPENAI_API_BASE\"] = userdata.get('MOON_API_BASE')\n","os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n","os.environ[\"LANGCHAIN_API_KEY\"] = userdata.get('LANGCHAIN_API_KEY')"],"metadata":{"id":"yuSTrg9F18dk"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# 定义工具"],"metadata":{"id":"4O6cSFAO2CvM"}},{"cell_type":"markdown","source":["## 联网搜索工具Tavily"],"metadata":{"id":"zO13wVV92Ge6"}},{"cell_type":"markdown","source":["Tavily 是一个专为大型语言模型（LLMs）和检索式生成（RAG）优化的搜索引擎，旨在提供高效、快速且持久的搜索结果。"],"metadata":{"id":"RBfREy758IvW"}},{"cell_type":"code","source":["os.environ[\"TAVILY_API_KEY\"] = userdata.get('TAVILY_API_KEY')"],"metadata":{"id":"A1JJuzmu2CZ-"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["from langchain_community.tools.tavily_search import TavilySearchResults"],"metadata":{"id":"Voxjt-3V2bie"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["search = TavilySearchResults(max_results=2)"],"metadata":{"id":"mJEzc4FP2tZ1"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["search.invoke(\"what is the weather in SF\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"collapsed":true,"id":"wTx162Zt2xJH","executionInfo":{"status":"ok","timestamp":1719881234446,"user_tz":-480,"elapsed":2256,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"43cdc729-2bf8-464b-da33-cb703022c992"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[{'url': 'https://www.wunderground.com/hourly/us/ca/san-francisco/date/2024-07-02',\n","  'content': 'San Francisco Weather Forecasts. Weather Underground provides local & long-range weather forecasts, weatherreports, maps & tropical weather conditions for the San Francisco area. ... Tuesday 07/02 ...'},\n"," {'url': 'https://www.weatherapi.com/',\n","  'content': \"{'location': {'name': 'San Francisco', 'region': 'California', 'country': 'United States of America', 'lat': 37.78, 'lon': -122.42, 'tz_id': 'America/Los_Angeles', 'localtime_epoch': 1719881174, 'localtime': '2024-07-01 17:46'}, 'current': {'last_updated_epoch': 1719881100, 'last_updated': '2024-07-01 17:45', 'temp_c': 23.3, 'temp_f': 73.9, 'is_day': 1, 'condition': {'text': 'Sunny', 'icon': '//cdn.weatherapi.com/weather/64x64/day/113.png', 'code': 1000}, 'wind_mph': 15.0, 'wind_kph': 24.1, 'wind_degree': 290, 'wind_dir': 'WNW', 'pressure_mb': 1011.0, 'pressure_in': 29.85, 'precip_mm': 0.01, 'precip_in': 0.0, 'humidity': 50, 'cloud': 0, 'feelslike_c': 25.2, 'feelslike_f': 77.3, 'windchill_c': 17.5, 'windchill_f': 63.5, 'heatindex_c': 17.5, 'heatindex_f': 63.5, 'dewpoint_c': 11.8, 'dewpoint_f': 53.2, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 4.0, 'gust_mph': 15.5, 'gust_kph': 24.9}}\"}]"]},"metadata":{},"execution_count":7}]},{"cell_type":"markdown","source":["## 本地知识库检索工具"],"metadata":{"id":"e70vXmXA21Bd"}},{"cell_type":"code","source":["from langchain_community.document_loaders import WebBaseLoader\n","from langchain_community.vectorstores import FAISS\n","from langchain_openai import OpenAIEmbeddings\n","from langchain_text_splitters import RecursiveCharacterTextSplitter\n","# 加载网页内容\n","loader = WebBaseLoader(\"https://docs.smith.langchain.com/overview\")\n","docs = loader.load()\n","# 分割文本\n","documents = RecursiveCharacterTextSplitter(\n","    chunk_size=1000, chunk_overlap=200\n",").split_documents(docs)\n","# 生成嵌入向量并存储在FAISS向量数据库中\n","vector = FAISS.from_documents(documents, OpenAIEmbeddings(openai_api_base=userdata.get('OPENAI_API_BASE'),openai_api_key=userdata.get('OPENAI_API_KEY')))\n","retriever = vector.as_retriever()"],"metadata":{"id":"UNdqiHg525YZ"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["retriever.invoke(\"how to upload a dataset\")[0]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"XEhGfUzY3ci1","executionInfo":{"status":"ok","timestamp":1716775415507,"user_tz":-480,"elapsed":1381,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"9a2f57c8-a29d-4c3b-f995-99c75695f944"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["Document(page_content='description=\"A sample dataset in LangSmith.\")client.create_examples(    inputs=[        {\"postfix\": \"to LangSmith\"},        {\"postfix\": \"to Evaluations in LangSmith\"},    ],    outputs=[        {\"output\": \"Welcome to LangSmith\"},        {\"output\": \"Welcome to Evaluations in LangSmith\"},    ],    dataset_id=dataset.id,)# Define your evaluatordef exact_match(run, example):    return {\"score\": run.outputs[\"output\"] == example.outputs[\"output\"]}experiment_results = evaluate(    lambda input: \"Welcome \" + input[\\'postfix\\'], # Your AI system goes here    data=dataset_name, # The data to predict and grade over    evaluators=[exact_match], # The evaluators to score the results    experiment_prefix=\"sample-experiment\", # The name of the experiment    metadata={      \"version\": \"1.0.0\",      \"revision_id\": \"beta\"    },)import { Client, Run, Example } from \"langsmith\";import { evaluate } from \"langsmith/evaluation\";import { EvaluationResult } from \"langsmith/evaluation\";const client = new', metadata={'source': 'https://docs.smith.langchain.com/overview', 'title': 'Get started with LangSmith | \\uf8ffü¶úÔ∏è\\uf8ffüõ†Ô∏è LangSmith', 'description': 'LangSmith is a platform for building production-grade LLM applications. It allows you to closely monitor and evaluate your application, so you can ship quickly and with confidence. Use of LangChain is not necessary - LangSmith works on its own!', 'language': 'en'})"]},"metadata":{},"execution_count":10}]},{"cell_type":"markdown","source":["将retriever封装为一个工具供智能体调用"],"metadata":{"id":"OZmETP0U3iXW"}},{"cell_type":"code","source":["from langchain.tools.retriever import create_retriever_tool\n","retriever_tool = create_retriever_tool(\n","    retriever,\n","\"langsmith_search\",\n","\"Search for information about LangSmith. For any questions about LangSmith, you must use this tool!\",\n",")\n"],"metadata":{"id":"97nERr1T3og9"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["## 创建工具集"],"metadata":{"id":"HtP-MHsG31oj"}},{"cell_type":"code","source":["tools = [search, retriever_tool]"],"metadata":{"id":"TspGSk5A3yJn"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["# 大模型调用"],"metadata":{"id":"uI8EZOy-37wa"}},{"cell_type":"code","source":["from langchain_openai import ChatOpenAI\n","model = ChatOpenAI(model=\"moonshot-v1-32k\")"],"metadata":{"id":"Jk89NiSK4AtA"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["简单调用"],"metadata":{"id":"3Nj71MNo4HVr"}},{"cell_type":"code","source":["from langchain_core.messages import HumanMessage\n","response = model.invoke([HumanMessage(content=\"hi!\")])\n","response.content"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":35},"id":"ecsEHk6l4C1K","executionInfo":{"status":"ok","timestamp":1719882334910,"user_tz":-480,"elapsed":3763,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"9b69c4ef-20f6-4465-ca5f-0c6139b59b91"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["'Hello! How can I help you today? If you have any questions or need assistance, please feel free to ask.'"],"application/vnd.google.colaboratory.intrinsic+json":{"type":"string"}},"metadata":{},"execution_count":19}]},{"cell_type":"markdown","source":["## 模型绑定工具集"],"metadata":{"id":"uqSDyIeY5k01"}},{"cell_type":"code","source":["model_with_tools = model.bind_tools(tools)"],"metadata":{"id":"89pFnIcG5ZXc"},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":["不调用工具"],"metadata":{"id":"ThHZ2AIL5s98"}},{"cell_type":"code","source":["response = model_with_tools.invoke([HumanMessage(content=\"Hi!\")])\n","print(f\"ContentString: {response.content}\")\n","print(f\"ToolCalls: {response.tool_calls}\")\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"dakJIKCm5dYm","executionInfo":{"status":"ok","timestamp":1719882350752,"user_tz":-480,"elapsed":4551,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"27e23b63-f528-41b4-be36-7d366b967ed1"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["ContentString: Hello! How can I assist you today? If you have any questions or need help with something, feel free to ask.\n","ToolCalls: []\n"]}]},{"cell_type":"markdown","source":["调用联网检索工具"],"metadata":{"id":"dG3cJ-WP5vNE"}},{"cell_type":"code","source":["response = model_with_tools.invoke([HumanMessage(content=\"通过网络搜索，北京天气怎么样？\")])\n","print(f\"ContentString: {response.content}\")\n","print(f\"ToolCalls: {response.tool_calls}\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"20h2tjsg5i5Z","executionInfo":{"status":"ok","timestamp":1719882437214,"user_tz":-480,"elapsed":2052,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"fe8afc94-b0bd-42e6-84cd-9bdb8016ae9c"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["ContentString: \n","ToolCalls: [{'name': 'tavily_search_results_json', 'args': {'query': '北京 天气'}, 'id': 'tavily_search_results_json:0'}]\n"]}]},{"cell_type":"markdown","source":["# 创建智能体"],"metadata":{"id":"PCLgRyro59pZ"}},{"cell_type":"code","source":["from langgraph.prebuilt import chat_agent_executor\n","agent_executor = chat_agent_executor.create_tool_calling_executor(model, tools)"],"metadata":{"id":"KRpPf8dW6BOp"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["response = agent_executor.invoke({\"messages\": [HumanMessage(content=\"hi!\")]})\n","response[\"messages\"]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"hvD_1GeT6hsu","executionInfo":{"status":"ok","timestamp":1719882457030,"user_tz":-480,"elapsed":3770,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"21b1ca09-94b8-45f5-e37e-0a275121cc00"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[HumanMessage(content='hi!', id='e2e7c3aa-a7eb-48eb-8d29-10ac6e10e804'),\n"," AIMessage(content='Hello! How can I assist you today? If you have any questions or need help with something, feel free to ask.', response_metadata={'token_usage': {'completion_tokens': 26, 'prompt_tokens': 134, 'total_tokens': 160}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-51c68c2d-a53e-4b6e-8f16-f39f414d1403-0', usage_metadata={'input_tokens': 134, 'output_tokens': 26, 'total_tokens': 160})]"]},"metadata":{},"execution_count":27}]},{"cell_type":"markdown","source":["## 本地知识库工具调用"],"metadata":{"id":"9SjK4GKa6lDI"}},{"cell_type":"code","source":["from langchain_core.messages import HumanMessage\n","response = agent_executor.invoke(\n","{\"messages\": [HumanMessage(content=\"how can langsmith help with testing?\")]}\n",")\n","response[\"messages\"]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"s92x5cts6k0t","executionInfo":{"status":"ok","timestamp":1719882468876,"user_tz":-480,"elapsed":10560,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"60331939-3ac2-4e9d-aeb0-e62d7c1810ad"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[HumanMessage(content='how can langsmith help with testing?', id='fa0353f1-b8c1-409e-bf9b-ce0cb8987a38'),\n"," AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'langsmith_search:0', 'function': {'arguments': '{\\n    \"query\": \"langsmith testing\"\\n}', 'name': 'langsmith_search'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 14, 'prompt_tokens': 140, 'total_tokens': 154}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-4c939673-df53-43a4-a55b-3d92a36f3ab2-0', tool_calls=[{'name': 'langsmith_search', 'args': {'query': 'langsmith testing'}, 'id': 'langsmith_search:0'}], usage_metadata={'input_tokens': 140, 'output_tokens': 14, 'total_tokens': 154}),\n"," ToolMessage(content='Skip to main contentGo to API DocsSearchGo to AppQuick startTutorialsHow-to guidesConceptsReferencePricingSelf-hostingLangGraph CloudQuick startOn this pageGet started with LangSmithLangSmith is a platform for building production-grade LLM applications. It allows you to closely monitor and evaluate your application, so you can ship quickly and with confidence. Use of LangChain is not necessary - LangSmith works on its own!1. Install LangSmith‚ÄãPythonTypeScriptpip install -U langsmithyarn add langchain langsmith2. Create an API key‚ÄãTo create an API key head to the Settings page. Then click Create API Key.3. Set up your environment‚ÄãShellexport LANGCHAIN_TRACING_V2=trueexport LANGCHAIN_API_KEY=<your-api-key># The below examples use the OpenAI API, though it\\'s not necessary in generalexport OPENAI_API_KEY=<your-openai-api-key>4. Log your first trace‚ÄãWe provide multiple ways to log traces to LangSmith. Below, we\\'ll highlight\\n\\nGet started with LangSmith | \\uf8ffü¶úÔ∏è\\uf8ffüõ†Ô∏è LangSmith\\n\\n\"revision_id\": \"beta\"    },)import { Client, Run, Example } from \"langsmith\";import { evaluate } from \"langsmith/evaluation\";import { EvaluationResult } from \"langsmith/evaluation\";const client = new Client();// Define dataset: these are your test casesconst datasetName = \"Sample Dataset\";const dataset = await client.createDataset(datasetName, {  description: \"A sample dataset in LangSmith.\",});await client.createExamples({  inputs: [    { postfix: \"to LangSmith\" },    { postfix: \"to Evaluations in LangSmith\" },  ],  outputs: [    { output: \"Welcome to LangSmith\" },    { output: \"Welcome to Evaluations in LangSmith\" },  ],  datasetId: dataset.id,});// Define your evaluatorconst exactMatch = async (  run: Run,  example: Example): Promise<EvaluationResult> => {  return {    key: \"exact_match\",    score: run.outputs?.output === example?.outputs?.output,  };};await evaluate(  (input: { postfix: string }) => ({ output: `Welcome ${input.postfix}` }),  {    data: datasetName,    evaluators:\\n\\nscore: run.outputs?.output === example?.outputs?.output,  };};await evaluate(  (input: { postfix: string }) => ({ output: `Welcome ${input.postfix}` }),  {    data: datasetName,    evaluators: [exactMatch],    metadata: {      version: \"1.0.0\",      revision_id: \"beta\",    },  });Learn more about evaluation in the how-to guides.Was this page helpful?You can leave detailed feedback on GitHub.NextTutorials1. Install LangSmith2. Create an API key3. Set up your environment4. Log your first trace5. Run your first evaluationCommunityDiscordTwitterGitHubDocs CodeLangSmith SDKPythonJS/TSMoreHomepageBlogLangChain Python DocsLangChain JS/TS DocsCopyright ¬© 2024 LangChain, Inc.', name='langsmith_search', id='09c6c000-f9f7-4b8c-8559-c7f9e7534990', tool_call_id='langsmith_search:0'),\n"," AIMessage(content=\"Langsmith is a platform that assists in testing by enabling developers to create datasets for evaluating the performance of AI models. It involves the following steps:\\n\\n1. Installing LangSmith using Python or TypeScript.\\n2. Creating an API key from the Settings page.\\n3. Setting up the environment with necessary API keys.\\n4. Defining a dataset with test cases.\\n5. Creating an evaluator to assess the AI model's responses.\\n6. Using the `evaluate` function to compare the model's outputs with expected results.\\n\\nThis testing platform helps in quickly identifying discrepancies in the AI model's behavior, allowing developers to enhance its performance before deployment.\", response_metadata={'token_usage': {'completion_tokens': 127, 'prompt_tokens': 883, 'total_tokens': 1010}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-cbbea0e7-68c0-46f4-9744-34ccec13b0c8-0', usage_metadata={'input_tokens': 883, 'output_tokens': 127, 'total_tokens': 1010})]"]},"metadata":{},"execution_count":28}]},{"cell_type":"markdown","source":["## 联网检索工具调用"],"metadata":{"id":"zJrFb5Bp6v5k"}},{"cell_type":"code","source":["response = agent_executor.invoke(\n","{\"messages\": [HumanMessage(content=\"通过网络搜索，北京天气怎么样？\")]}\n",")\n","response[\"messages\"]"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"UzXdhCk36vCZ","executionInfo":{"status":"ok","timestamp":1719882524184,"user_tz":-480,"elapsed":11131,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"feda34f4-ac87-44a7-b2cf-f025a55f7a52"},"execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[HumanMessage(content='通过网络搜索，北京天气怎么样？', id='1c89663a-04c9-481d-8b99-1dc44ce60da3'),\n"," AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'tavily_search_results_json:0', 'function': {'arguments': '{\\n    \"query\": \"北京 天气\"\\n}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 14, 'prompt_tokens': 140, 'total_tokens': 154}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-ede5d67a-8030-471b-9d5b-ad03d7bd67d2-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': '北京 天气'}, 'id': 'tavily_search_results_json:0'}], usage_metadata={'input_tokens': 140, 'output_tokens': 14, 'total_tokens': 154}),\n"," ToolMessage(content='[{\"url\": \"http://www.weather.com.cn/weather/101010100.shtml\", \"content\": \"\\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u6e29\\\\u5dee\\\\u8f83\\\\u5927\\\\uff0c\\\\u8f83\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u62a4\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u5916\\\\u5957\\\\u52a0\\\\u6bdb\\\\u8863\\\\u7b49\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8d44\\\\u8baf\\\\n\\\\u5468\\\\u8fb9\\\\u5730\\\\u533a\\\\n|\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n2023-11-28 11:30\\\\u66f4\\\\u65b0\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n\\\\u5468\\\\u8fb9\\\\u5730\\\\u533a\\\\n|\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n2023-11-28 11:30\\\\u66f4\\\\u65b0\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n\\\\u9ad8\\\\u6e05\\\\u56fe\\\\u96c6\\\\n\\\\u91cd\\\\u5927\\\\u5929\\\\u6c14\\\\u4e8b\\\\u4ef6\\\\n11\\\\u670828\\\\u65e5\\\\n\\\\u6708\\\\u5e95\\\\u524d\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u9891\\\\u7e41 \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u5c06\\\\u521b\\\\u65b0\\\\u4f4e\\\\n\\\\u4eca\\\\u5929\\\\u81f312\\\\u67081\\\\u65e5\\\\uff0c\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u81ea\\\\u5317\\\\u5411\\\\u5357\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\uff0c\\\\u897f\\\\u5317\\\\u3001\\\\u9ec4\\\\u6dee\\\\u7b49\\\\u5730\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u6e298\\\\uff5e10\\\\u2103\\\\uff0c\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u4f1a\\\\u5237\\\\u65b0\\\\u4eca\\\\u51ac\\\\u4ee5\\\\u6765\\\\u65b0\\\\u4f4e\\\\u3002\\\\n11\\\\u670827\\\\u65e5\\\\n\\\\u5317\\\\u65b9\\\\u672c\\\\u5468\\\\u521d\\\\u964d\\\\u96ea\\\\u7ee7\\\\u7eed\\\\u53d1\\\\u5c55 \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u6c14\\\\u6e29\\\\u9707\\\\u8361\\\\u4e0b\\\\u6ed1\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670827\\\\u65e5\\\\uff09\\\\uff0c\\\\u964d\\\\u96ea\\\\u533a\\\\u57df\\\\u4e3b\\\\u8981\\\\u4f4d\\\\u4e8e\\\\u9ed1\\\\u9f99\\\\u6c5f\\\\u3001\\\\u5409\\\\u6797\\\\u3001\\\\u5c71\\\\u4e1c\\\\u534a\\\\u5c9b\\\\u5317\\\\u90e8\\\\u7b49\\\\u5730\\\\uff0c\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u6c34\\\\u8f83\\\\u5f3a\\\\uff1b\\\\u53e6\\\\u5916\\\\uff0c\\\\u4f4d\\\\u4e8e\\\\u897f\\\\u90e8\\\\u5730\\\\u533a\\\\u7684\\\\u9752\\\\u6d77\\\\u3001\\\\u897f\\\\u85cf\\\\u7b49\\\\u5730\\\\u4e5f\\\\u5c06\\\\u6709\\\\u964d\\\\u96ea\\\\u53d1\\\\u5c55\\\\u3002\\\\n11\\\\u670826\\\\u65e5\\\\n\\\\u4eca\\\\u8d77\\\\u4e1c\\\\u5317\\\\u7b49\\\\u5730\\\\u8fce\\\\u660e\\\\u663e\\\\u964d\\\\u96ea \\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\u957f\\\\u6c5f\\\\u4ee5\\\\u5317\\\\n\\\\u4eca\\\\u660e\\\\u4e24\\\\u5929\\\\uff0811\\\\u670826\\\\u65e5\\\\u81f327\\\\u65e5\\\\uff09\\\\uff0c\\\\u6211\\\\u56fd\\\\u964d\\\\u6c34\\\\u4e3b\\\\u8981\\\\u51fa\\\\u73b0\\\\u5728\\\\u4e1c\\\\u5317\\\\u7b49\\\\u5730\\\\u3002\\\\u540c\\\\u65f6\\\\uff0c\\\\u968f\\\\u7740\\\\u65b0\\\\u4e00\\\\u8f6e\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u767b\\\\u573a\\\\uff0c\\\\u957f\\\\u6c5f\\\\u4ee5\\\\u5317\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u6c14\\\\u6e29\\\\u4e0b\\\\u964d\\\\u660e\\\\u663e\\\\uff0c\\\\u5e76\\\\u4f34\\\\u6709\\\\u5927\\\\u98ce\\\\u5929\\\\u6c14\\\\u3002\\\\n11\\\\u670825\\\\u65e5\\\\n\\\\u65b0\\\\u4e00\\\\u80a1\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u660e\\\\u5929\\\\u201c\\\\u53d1\\\\u8d27\\\\u201d \\\\u4e1c\\\\u5317\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u518d\\\\u53d1\\\\u5c55\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670825\\\\u65e5\\\\uff09\\\\uff0c\\\\u5bd2\\\\u6f6e\\\\u5f71\\\\u54cd\\\\u8fc7\\\\u7a0b\\\\u7ed3\\\\u675f\\\\uff0c\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u5f00\\\\u542f\\\\u5347\\\\u6e29\\\\u6a21\\\\u5f0f\\\\u3002\\\\u4f46\\\\u65b0\\\\u4e00\\\\u80a1\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5df2\\\\u7ecf\\\\u5728\\\\u8def\\\\u4e0a\\\\u4e86\\\\uff0126\\\\u65e5\\\\u81f328\\\\u65e5\\\\uff0c\\\\u4e00\\\\u80a1\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5c06\\\\u81ea\\\\u5317\\\\u5411\\\\u5357\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u3002\\\\n11\\\\u670824\\\\u65e5\\\\n\\\\u5bd2\\\\u6f6e\\\\u5357\\\\u4e0b\\\\u964d\\\\u6e29\\\\u5f71\\\\u54cd\\\\u6ce2\\\\u53ca\\\\u6c5f\\\\u5357 \\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u6674\\\\u5929\\\\u4e3a\\\\u4e3b\\\\u5b9c\\\\u51fa\\\\u884c\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670824\\\\u65e5\\\\uff09\\\\uff0c\\\\u5bd2\\\\u6f6e\\\\u8fdb\\\\u4e00\\\\u6b65\\\\u5357\\\\u4e0b\\\\uff0c\\\\u6c5f\\\\u5357\\\\u52a0\\\\u5165\\\\u964d\\\\u6e29\\\\u884c\\\\u5217\\\\uff0c\\\\u540c\\\\u65f6\\\\uff0c\\\\u5317\\\\u65b9\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u7ee7\\\\u7eed\\\\u4e0b\\\\u6ed1\\\\uff0c\\\\u4e1c\\\\u5317\\\\u3001\\\\u534e\\\\u5317\\\\u591a\\\\u5730\\\\u5c06\\\\u521b\\\\u4eca\\\\u5e74\\\\u4e0b\\\\u534a\\\\u5e74\\\\u6765\\\\u6c14\\\\u6e29\\\\u65b0\\\\u4f4e\\\\uff0c\\\\u516c\\\\u4f17\\\\u9700\\\\u52a0\\\\u5f3a\\\\u4fdd\\\\u6696\\\\u5de5\\\\u4f5c\\\\u3002\\\\n11\\\\u670823\\\\u65e5\\\\n\\\\u4eca\\\\u51ac\\\\u7b2c\\\\u4e8c\\\\u8f6e\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u4e1c\\\\u79fb\\\\u5357\\\\u4e0b \\\\u534e\\\\u5317\\\\u9ec4\\\\u6dee\\\\u7b49\\\\u5730\\\\u964d\\\\u6e29\\\\u731b\\\\u70c8\\\\n\\\\u4eca\\\\u660e\\\\u5929\\\\uff0811\\\\u670823\\\\u65e5\\\\u81f324\\\\u65e5\\\\uff09\\\\uff0c\\\\u4eca\\\\u51ac\\\\u7b2c\\\\u4e8c\\\\u8f6e\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u5357\\\\u4e0b\\\\uff0c\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u3002\\\\u5176\\\\u4e2d\\\\u4eca\\\\u5929\\\\u4ecd\\\\u662f\\\\u964d\\\\u6e29\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5\\\\u3002\\\\n11\\\\u670822\\\\u65e5\\\\n\\\\u4eca\\\\u8d77\\\\u5bd2\\\\u6f6e\\\\u5f71\\\\u54cd\\\\u8fdb\\\\u5165\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5 \\\\u4e1c\\\\u5317\\\\u5c06\\\\u6709\\\\u5927\\\\u5230\\\\u66b4\\\\u96ea\\\\u6c14\\\\u6e29\\\\u731b\\\\u8dcc\\\\n\\\\u4eca\\\\u8d77\\\\u4e09\\\\u5929\\\\uff0811\\\\u670822\\\\u65e5\\\\u81f324\\\\u65e5\\\\uff09\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u5411\\\\u4e1c\\\\u6269\\\\u5c55\\\\uff0c\\\\u8fce\\\\u6765\\\\u5927\\\\u98ce\\\\u3001\\\\u964d\\\\u6e29\\\\u5f71\\\\u54cd\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5\\\\uff0c\\\\u9700\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n11\\\\u670821\\\\u65e5\\\\n11\\\\u6708\\\\u7b2c\\\\u4e8c\\\\u573a\\\\u5bd2\\\\u6f6e\\\\u6765\\\\u88ad \\\\u5317\\\\u65b9\\\\u8fce\\\\u5267\\\\u70c8\\\\u964d\\\\u6e29\\\\n\\\\u4eca\\\\u5929\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u4ecd\\\\u5ef6\\\\u7eed\\\\u6674\\\\u6717\\\\u5347\\\\u6e29\\\\u6a21\\\\u5f0f\\\\uff0c\\\\u4e0e\\\\u6b64\\\\u540c\\\\u65f6\\\\uff0c\\\\u4eca\\\\u5e7411\\\\u6708\\\\u7b2c\\\\u4e8c\\\\u573a\\\\u5bd2\\\\u6f6e\\\\u5df2\\\\u7ecf\\\\u542f\\\\u7a0b\\\\uff0c\\\\u4eca\\\\u8d77\\\\u81f324\\\\u65e5\\\\u5c06\\\\u81ea\\\\u897f\\\\u5411\\\\u4e1c\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u3002\\\\n11\\\\u670819\\\\u65e5\\\\n\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u6301\\\\u7eed\\\\u5347\\\\u6e29 \\\\u534e\\\\u5317\\\\u7b49\\\\u5730\\\\u96fe\\\\u548c\\\\u973e\\\\u5929\\\\u6c14\\\\u53d1\\\\u5c55\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670819\\\\u65e5\\\\uff09\\\\u81f322\\\\u65e5\\\\uff0c\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5c06\\\\u6301\\\\u7eed\\\\u5347\\\\u6e29\\\\uff0c\\\\u6674\\\\u5929\\\\u4e3a\\\\u4e3b\\\\uff0c\\\\u964d\\\\u6c34\\\\u7a00\\\\u5c11\\\\u300222\\\\u65e5\\\\u524d\\\\u540e\\\\uff0c\\\\u5404\\\\u5730\\\\u6c14\\\\u6e29\\\\u5c06\\\\u8fce\\\\u6765\\\\u8fd1\\\\u671f\\\\u9ad8\\\\u70b9\\\\u3002\\\\n11\\\\u670818\\\\u65e5\\\\n\\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u7ef4\\\\u6301\\\\u6674\\\\u6717\\\\u5e72\\\\u71e5 \\\\u6c14\\\\u6e29\\\\u5c06\\\\u9646\\\\u7eed\\\\u56de\\\\u5347\\\\u81f3\\\\u5e38\\\\u5e74\\\\u540c\\\\u671f\\\\u504f\\\\u9ad8\\\\u72b6\\\\u6001\\\\n\\\\u672a\\\\u6765\\\\u4e09\\\\u5929\\\\uff0811\\\\u670818\\\\u65e5\\\\u81f320\\\\u65e5\\\\uff09\\\\uff0c\\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u5c06\\\\u7ef4\\\\u6301\\\\u6674\\\\u6717\\\\u5e72\\\\u71e5\\\\u7684\\\\u5929\\\\u6c14\\\\u683c\\\\u5c40\\\\uff0c\\\\u6c14\\\\u6e29\\\\u4e5f\\\\u5c06\\\\u9010\\\\u6e10\\\\u56de\\\\u5347\\\\u3002\\\\n11\\\\u670817\\\\u65e5\\\\n\\\\u4e1c\\\\u5317\\\\u964d\\\\u96ea\\\\u8fdb\\\\u5165\\\\u6700\\\\u5f3a\\\\u65f6\\\\u6bb5\\\\u5c40\\\\u5730\\\\u5c06\\\\u906d\\\\u5927\\\\u66b4\\\\u96ea \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u7b49\\\\u5730\\\\u964d\\\\u6e29\\\\u6301\\\\u7eed\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670817\\\\u65e5\\\\uff09\\\\uff0c\\\\u4e1c\\\\u5317\\\\u5927\\\\u8303\\\\u56f4\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u6301\\\\u7eed\\\\uff0c\\\\u9ed1\\\\u9f99\\\\u6c5f\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u3001\\\\u5409\\\\u6797\\\\u4e1c\\\\u90e8\\\\u7b49\\\\u5c40\\\\u5730\\\\u6216\\\\u906d\\\\u9047\\\\u5927\\\\u66b4\\\\u96ea\\\\uff0c\\\\u9700\\\\u8b66\\\\u60d5\\\\u79ef\\\\u96ea\\\\u6210\\\\u707e\\\\u3002\\\\u53d7\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\uff0c\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u7b49\\\\u5730\\\\u6c14\\\\u6e29\\\\u7ee7\\\\u7eed\\\\u4e0b\\\\u964d\\\\u3002\\\\n11\\\\u670816\\\\u65e5\\\\n\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8 \\\\u4e1c\\\\u5317\\\\u5c40\\\\u5730\\\\u6709\\\\u7279\\\\u5927\\\\u66b4\\\\u96ea\\\\n\\\\u4eca\\\\u660e\\\\u5929\\\\uff0811\\\\u670816\\\\u65e5\\\\u81f317\\\\u65e5\\\\uff09\\\\uff0c\\\\u4e1c\\\\u5317\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u96ea\\\\u8f83\\\\u5f3a\\\\uff0c\\\\u5c40\\\\u5730\\\\u6709\\\\u7279\\\\u5927\\\\u66b4\\\\u96ea\\\\u3002\\\\u540c\\\\u65f6\\\\uff0c\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5357\\\\u4e0b\\\\u5f71\\\\u54cd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u3002\\\\n11\\\\u670815\\\\u65e5\\\\n\\\\u65b0\\\\u4e00\\\\u8f6e\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u6765\\\\u88ad\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u8d77\\\\u4f0f \\\\u4e1c\\\\u5317\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u5c06\\\\u73b0\\\\u8f83\\\\u5f3a\\\\u964d\\\\u96ea\\\\n\\\\u9884\\\\u8ba1\\\\u4eca\\\\u5929\\\\uff0811\\\\u670815\\\\u65e5\\\\uff09\\\\u8d77\\\\u81f317\\\\u65e5\\\\uff0c\\\\u4e00\\\\u80a1\\\\u4e2d\\\\u7b49\\\\u5f3a\\\\u5ea6\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5c06\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5730\\\\u533a\\\\uff0c\\\\u4e0d\\\\u4ec5\\\\u5927\\\\u98ce\\\\u964d\\\\u6e29\\\\u5929\\\\u6c14\\\\u4e0d\\\\u4f1a\\\\u7f3a\\\\u5e2d\\\\uff0c\\\\u800c\\\\u4e14\\\\u4e1c\\\\u5317\\\\u5730\\\\u533a\\\\u8fd8\\\\u5c06\\\\u51fa\\\\u73b0\\\\u8f83\\\\u5f3a\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u3002\\\\n\\\\u8054\\\\u64ad\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\n\\\\u66f4\\\\u591a>>\\\\u9ad8\\\\u6e05\\\\u56fe\\\\u96c6\\\\n\\\\u5929\\\\u6c14\\\\u89c6\\\\u9891\\\\n\\\\u536b\\\\u661f\\\\u4e91\\\\u56fe\\\\u770b\\\\u5c71\\\\u4e1c\\\\u201c\\\\u96ea\\\\u7a9d\\\\u201d\\\\u51b7\\\\u6d41\\\\u964d\\\\u96ea\\\\n\\\\u96e8\\\\u96ea\\\\u5306\\\\u5306\\\\u8fc7 \\\\u6d17\\\\u8f66\\\\u6709\\\\u673a\\\\u4f1a\\\\n>> \\\\u751f\\\\u6d3b\\\\u65c5\\\\u6e38\\\\n\\\\u666f\\\\u70b9\\\\u63a8\\\\u8350\\\\n\\\\u6c14\\\\u8c61\\\\u4ea7\\\\u54c1\\\\n\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\n\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\u70ed\\\\u7ebf\\\\n\\\\u62e8\\\\u6253400-6000-121\\\\u8fdb\\\\u884c\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\u54a8\\\\u8be2\\\\u3001\\\\u5efa\\\\u8bae\\\\u3001\\\\u5408\\\\u4f5c\\\\u4e0e\\\\u6295\\\\u8bc9\\\\n\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\u7535\\\\u8bdd\\\\u67e5\\\\u8be2\\\\n\\\\u62e8\\\\u625312121\\\\u621696121\\\\u8fdb\\\\u884c\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\u67e5\\\\u8be2\\\\n\\\\u624b\\\\u673a\\\\u67e5\\\\u8be2\\\\n\\\\u968f\\\\u65f6\\\\u968f\\\\u5730\\\\u901a\\\\u8fc7\\\\u624b\\\\u673a\\\\u767b\\\\u5f55\\\\u4e2d\\\\u56fd\\\\u5929\\\\u6c14WAP\\\\u7248\\\\u67e5\\\\u770b\\\\u5404\\\\u5730\\\\u5929\\\\u6c14\\\\u8d44\\\\u8baf\\\\n\\\\u7f51\\\\u7ad9\\\\u670d\\\\u52a1\\\\n\\\\u5173\\\\u4e8e\\\\u6211\\\\u4eec\\\\u8054\\\\u7cfb\\\\u6211\\\\u4eec\\\\u5e2e\\\\u52a9\\\\u4eba\\\\u5458\\\\u62db\\\\u8058\\\\n\\\\u5ba2\\\\u670d\\\\u4e2d\\\\u5fc3\\\\u7248\\\\u6743\\\\u58f0\\\\u660e\\\\u5f8b\\\\u5e08\\\\u7f51\\\\u7ad9\\\\u5730\\\\u56fe\\\\n\\\\u8425\\\\u9500\\\\u4e2d\\\\u5fc3\\\\n\\\\u5546\\\\u52a1\\\\u5408\\\\u4f5c\\\\u5e7f\\\\u544a\\\\u670d\\\\u52a1\\\\u5a92\\\\u8d44\\\\u5408\\\\u4f5c\\\\n \\\\u53f0\\\\u98ce\\\\u8def\\\\u5f84\\\\n\\\\u7a7a\\\\u95f4\\\\u5929\\\\u6c14\\\\n\\\\u56fe\\\\u7247\\\\n\\\\u4e13\\\\u9898\\\\n\\\\u73af\\\\u5883\\\\n\\\\u65c5\\\\u6e38\\\\n\\\\u751f\\\\u6001\\\\n\\\\u6c14\\\\u8c61\\\\u79d1\\\\u666e\\\\n\\\\u4e00\\\\u5e26\\\\u4e00\\\\u8def\\\\n\\\\u4ea7\\\\u521b\\\\u5e73\\\\u53f0\\\\n\\\\u70ed\\\\u95e8\\\\u57ce\\\\u5e02\\\\n\\\\u70ed\\\\u95e8\\\\u666f\\\\u70b9\\\\n\\\\u9009\\\\u62e9\\\\u7701\\\\u5e02\\\\n<<\\\\u8fd4\\\\u56de\\\\n\\\\u5168\\\\u56fd\\\\n\\\\u5468\\\\u8fb9\\\\u57ce\\\\u5e02\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n\\\\u672c\\\\u5730\\\\u4e61\\\\u9547\\\\n\\\\u70ed\\\\u95e8\\\\u57ce\\\\u5e02\\\\n\\\\u9009\\\\u62e9\\\\u6d32\\\\u9645\\\\n28\\\\u65e5\\\\uff08\\\\u4eca\\\\u5929\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n3/-4\\\\u2103\\\\n<3\\\\u7ea7\\\\u8f6c3-4\\\\u7ea7\\\\n29\\\\u65e5\\\\uff08\\\\u660e\\\\u5929\\\\uff09\\\\n\\\\u6674\\\\n3/-5\\\\u2103\\\\n3-4\\\\u7ea7\\\\u8f6c<3\\\\u7ea7\\\\n30\\\\u65e5\\\\uff08\\\\u540e\\\\u5929\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n4/-5\\\\u2103\\\\n<3\\\\u7ea7\\\\n1\\\\u65e5\\\\uff08\\\\u5468\\\\u4e94\\\\uff09\\\\n\\\\u6674\\\\n 6/-4\\\\u2103\\\\n<3\\\\u7ea7\\\\n2\\\\u65e5\\\\uff08\\\\u5468\\\\u516d\\\\uff09\\\\n\\\\u6674\\\\n8/-3\\\\u2103\\\\n<3\\\\u7ea7\\\\n3\\\\u65e5\\\\uff08\\\\u5468\\\\u65e5\\\\uff09\\\\n\\\\u6674\\\\n8/-3\\\\u2103\\\\n<3\\\\u7ea7\\\\n4\\\\u65e5\\\\uff08\\\\u5468\\\\u4e00\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n9/-2\\\\u2103\\\\n<3\\\\u7ea7\\\\n\\\\u84dd\\\\u5929\\\\u9884\\\\u62a5\\\\u7efc\\\\u5408\\\\u5929\\\\u6c14\\\\u73b0\\\\u8c61\\\\u3001\\\\u80fd\\\\u89c1\\\\u5ea6\\\\u3001\\\\u7a7a\\\\u6c14\\\\u8d28\\\\u91cf\\\\u7b49\\\\u56e0\\\\u5b50\\\\uff0c\\\\u9884\\\\u6d4b\\\\u672a\\\\u6765\\\\u4e00\\\\u5468\\\\u7684\\\\u5929\\\\u7a7a\\\\u72b6\\\\u51b5\\\\u3002\\\\n\\\\u5f3a\\\\u964d\\\\u6e29\\\\uff0c\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u6781\\\\u6613\\\\u53d1\\\\u751f\\\\u611f\\\\u5192\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u63a8\\\\u8350\\\\u60a8\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u98ce\\\\u529b\\\\u8f83\\\\u5927\\\\uff0c\\\\u6d17\\\\u8f66\\\\u540e\\\\u4f1a\\\\u8499\\\\u4e0a\\\\u7070\\\\u5c18\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u98ce\\\\u529b\\\\u8f83\\\\u5f3a\\\\uff0c\\\\u8bf7\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u98ce\\\\u529b\\\\u8f83\\\\u5927\\\\uff0c\\\\u6d17\\\\u8f66\\\\u540e\\\\u4f1a\\\\u8499\\\\u4e0a\\\\u7070\\\\u5c18\\\\u3002\\\\n \\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u63a8\\\\u8350\\\\u60a8\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u68c9\\\\u8863\\\\u52a0\\\\u7f8a\\\\u6bdb\\\\u886b\\\\u7b49\\\\u51ac\\\\u5b63\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n \\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u6e29\\\\u5dee\\\\u8f83\\\\u5927\\\\uff0c\\\\u8f83\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u62a4\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u5916\\\\u5957\\\\u52a0\\\\u6bdb\\\\u8863\\\\u7b49\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\"}, {\"url\": \"http://www.nmc.cn/publish/forecast/ABJ/beijing.html\", \"content\": \"\\\\u5168\\\\u7403\\\\u5929\\\\u6c14\\\\u516c\\\\u62a5; \\\\u5168\\\\u7403\\\\u70ed\\\\u5e26\\\\u6c14\\\\u65cb\\\\u76d1\\\\u6d4b\\\\u516c\\\\u62a5; wmo\\\\u7b2cxi\\\\u6d77\\\\u533a\\\\u6d77\\\\u4e8b\\\\u5929\\\\u6c14\\\\u516c\\\\u62a5; \\\\u56fd\\\\u5916\\\\u519c\\\\u4e1a\\\\u6c14\\\\u8c61\\\\u76d1\\\\u6d4b\\\\u4e0e\\\\u4f5c\\\\u7269\\\\u5c55\\\\u671b; \\\\u5168\\\\u7403\\\\u707e\\\\u5bb3\\\\u6027\\\\u5929\\\\u6c14\\\\u76d1\\\\u6d4b\\\\u6708\\\\u62a5; \\\\u5168\\\\u7403\\\\u96e8\\\\u96ea\\\\u843d\\\\u533a\\\\u9884\\\\u62a5; \\\\u4e16\\\\u754c\\\\u6c14\\\\u8c61\\\\u4e2d\\\\u5fc3\\\\uff08\\\\u5317\\\\u4eac\\\\uff09\\\\u95e8\\\\u6237\\\\u7f51; \\\\u4e00\\\\u5e26\\\\u4e00\\\\u8def\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1; \\\\u4e9a\\\\u6d32\\\\u6c99\\\\u5c18\\\\u66b4\\\\u9884\\\\u62a5\\\\u4e13\\\\u4e1a\\\\u6c14\\\\u8c61\\\\u4e2d\\\\u5fc3\"}]', name='tavily_search_results_json', id='6d1613b9-a808-4f22-a074-348d872b7095', tool_call_id='tavily_search_results_json:0'),\n"," AIMessage(content='根据查询结果，北京的天气情况如下：\\n- 今天的天气较冷，建议进行室内运动。\\n- 风力较大，驾车出行时应注意。\\n- 空气质量较好，适合洗车。\\n- 紫外线较强，外出时建议涂抹高SPF值和PA值的防晒产品。\\n- 气温较低，外出时请注意保暖，建议穿着厚外套等冬季服装。\\n- 未来几天，北京将持续晴朗干燥的天气，气温将逐渐回升，但早晚温差较大，仍需注意添衣保暖。', response_metadata={'token_usage': {'completion_tokens': 106, 'prompt_tokens': 8351, 'total_tokens': 8457}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-309520d5-fd63-4363-8679-4918c2130f05-0', usage_metadata={'input_tokens': 8351, 'output_tokens': 106, 'total_tokens': 8457})]"]},"metadata":{},"execution_count":30}]},{"cell_type":"markdown","source":["# 响应返回"],"metadata":{"id":"CF63MVRt7Hwm"}},{"cell_type":"markdown","source":["## 流式响应"],"metadata":{"id":"EFlrAprX62gz"}},{"cell_type":"code","source":["for chunk in agent_executor.stream(\n","{\"messages\": [HumanMessage(content=\"通过网络搜索，北京当天气温多少度？\")]}\n","):\n","  print(chunk)\n","  print(\"----\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"99R7GluD62BT","executionInfo":{"status":"ok","timestamp":1719882598522,"user_tz":-480,"elapsed":16188,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"e71bc1fa-67e1-4361-ed00-898f329e7e61"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'agent': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'tavily_search_results_json:0', 'function': {'arguments': '{\\n    \"query\": \"北京 当天气温\"\\n}', 'name': 'tavily_search_results_json'}, 'type': 'function', 'index': 0}]}, response_metadata={'token_usage': {'completion_tokens': 15, 'prompt_tokens': 142, 'total_tokens': 157}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-c27f126f-3609-466d-bc7d-dd96b7d9bc4b-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': '北京 当天气温'}, 'id': 'tavily_search_results_json:0'}], usage_metadata={'input_tokens': 142, 'output_tokens': 15, 'total_tokens': 157})]}}\n","----\n","{'tools': {'messages': [ToolMessage(content='[{\"url\": \"http://www.nmc.cn/publish/forecast/ABJ/beijing.html\", \"content\": \"\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5 . \\\\u5929\\\\u6c14\\\\u516c\\\\u62a5. \\\\u6bcf\\\\u65e5\\\\u5929\\\\u6c14\\\\u63d0\\\\u793a ... \\\\u5236\\\\u4f5c\\\\u7ef4\\\\u62a4\\\\uff1a\\\\u56fd\\\\u5bb6\\\\u6c14\\\\u8c61\\\\u4e2d\\\\u5fc3\\\\u9884\\\\u62a5\\\\u7cfb\\\\u7edf\\\\u5f00\\\\u653e\\\\u5b9e\\\\u9a8c\\\\u5ba4 \\\\u5730\\\\u5740\\\\uff1a\\\\u5317\\\\u4eac\\\\u5e02\\\\u4e2d\\\\u5173\\\\u6751\\\\u5357\\\\u5927\\\\u885746\\\\u53f7 \\\\u90ae\\\\u7f16\\\\uff1a100081 . \\\\u4eac\\\\u516c\\\\u7f51\\\\u5b89\\\\u5907 11040102700100 ...\"}, {\"url\": \"http://www.weather.com.cn/weather/101010100.shtml\", \"content\": \"\\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u6e29\\\\u5dee\\\\u8f83\\\\u5927\\\\uff0c\\\\u8f83\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u62a4\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u5916\\\\u5957\\\\u52a0\\\\u6bdb\\\\u8863\\\\u7b49\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8d44\\\\u8baf\\\\n\\\\u5468\\\\u8fb9\\\\u5730\\\\u533a\\\\n|\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n2023-11-28 11:30\\\\u66f4\\\\u65b0\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n\\\\u5468\\\\u8fb9\\\\u5730\\\\u533a\\\\n|\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n2023-11-28 11:30\\\\u66f4\\\\u65b0\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n/\\\\n\\\\u9ad8\\\\u6e05\\\\u56fe\\\\u96c6\\\\n\\\\u91cd\\\\u5927\\\\u5929\\\\u6c14\\\\u4e8b\\\\u4ef6\\\\n11\\\\u670828\\\\u65e5\\\\n\\\\u6708\\\\u5e95\\\\u524d\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u9891\\\\u7e41 \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u5c06\\\\u521b\\\\u65b0\\\\u4f4e\\\\n\\\\u4eca\\\\u5929\\\\u81f312\\\\u67081\\\\u65e5\\\\uff0c\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u81ea\\\\u5317\\\\u5411\\\\u5357\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\uff0c\\\\u897f\\\\u5317\\\\u3001\\\\u9ec4\\\\u6dee\\\\u7b49\\\\u5730\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u6e298\\\\uff5e10\\\\u2103\\\\uff0c\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u4f1a\\\\u5237\\\\u65b0\\\\u4eca\\\\u51ac\\\\u4ee5\\\\u6765\\\\u65b0\\\\u4f4e\\\\u3002\\\\n11\\\\u670827\\\\u65e5\\\\n\\\\u5317\\\\u65b9\\\\u672c\\\\u5468\\\\u521d\\\\u964d\\\\u96ea\\\\u7ee7\\\\u7eed\\\\u53d1\\\\u5c55 \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u6c14\\\\u6e29\\\\u9707\\\\u8361\\\\u4e0b\\\\u6ed1\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670827\\\\u65e5\\\\uff09\\\\uff0c\\\\u964d\\\\u96ea\\\\u533a\\\\u57df\\\\u4e3b\\\\u8981\\\\u4f4d\\\\u4e8e\\\\u9ed1\\\\u9f99\\\\u6c5f\\\\u3001\\\\u5409\\\\u6797\\\\u3001\\\\u5c71\\\\u4e1c\\\\u534a\\\\u5c9b\\\\u5317\\\\u90e8\\\\u7b49\\\\u5730\\\\uff0c\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u6c34\\\\u8f83\\\\u5f3a\\\\uff1b\\\\u53e6\\\\u5916\\\\uff0c\\\\u4f4d\\\\u4e8e\\\\u897f\\\\u90e8\\\\u5730\\\\u533a\\\\u7684\\\\u9752\\\\u6d77\\\\u3001\\\\u897f\\\\u85cf\\\\u7b49\\\\u5730\\\\u4e5f\\\\u5c06\\\\u6709\\\\u964d\\\\u96ea\\\\u53d1\\\\u5c55\\\\u3002\\\\n11\\\\u670826\\\\u65e5\\\\n\\\\u4eca\\\\u8d77\\\\u4e1c\\\\u5317\\\\u7b49\\\\u5730\\\\u8fce\\\\u660e\\\\u663e\\\\u964d\\\\u96ea \\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\u957f\\\\u6c5f\\\\u4ee5\\\\u5317\\\\n\\\\u4eca\\\\u660e\\\\u4e24\\\\u5929\\\\uff0811\\\\u670826\\\\u65e5\\\\u81f327\\\\u65e5\\\\uff09\\\\uff0c\\\\u6211\\\\u56fd\\\\u964d\\\\u6c34\\\\u4e3b\\\\u8981\\\\u51fa\\\\u73b0\\\\u5728\\\\u4e1c\\\\u5317\\\\u7b49\\\\u5730\\\\u3002\\\\u540c\\\\u65f6\\\\uff0c\\\\u968f\\\\u7740\\\\u65b0\\\\u4e00\\\\u8f6e\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u767b\\\\u573a\\\\uff0c\\\\u957f\\\\u6c5f\\\\u4ee5\\\\u5317\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u6c14\\\\u6e29\\\\u4e0b\\\\u964d\\\\u660e\\\\u663e\\\\uff0c\\\\u5e76\\\\u4f34\\\\u6709\\\\u5927\\\\u98ce\\\\u5929\\\\u6c14\\\\u3002\\\\n11\\\\u670825\\\\u65e5\\\\n\\\\u65b0\\\\u4e00\\\\u80a1\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u660e\\\\u5929\\\\u201c\\\\u53d1\\\\u8d27\\\\u201d \\\\u4e1c\\\\u5317\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u518d\\\\u53d1\\\\u5c55\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670825\\\\u65e5\\\\uff09\\\\uff0c\\\\u5bd2\\\\u6f6e\\\\u5f71\\\\u54cd\\\\u8fc7\\\\u7a0b\\\\u7ed3\\\\u675f\\\\uff0c\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u5f00\\\\u542f\\\\u5347\\\\u6e29\\\\u6a21\\\\u5f0f\\\\u3002\\\\u4f46\\\\u65b0\\\\u4e00\\\\u80a1\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5df2\\\\u7ecf\\\\u5728\\\\u8def\\\\u4e0a\\\\u4e86\\\\uff0126\\\\u65e5\\\\u81f328\\\\u65e5\\\\uff0c\\\\u4e00\\\\u80a1\\\\u8f83\\\\u5f3a\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5c06\\\\u81ea\\\\u5317\\\\u5411\\\\u5357\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u3002\\\\n11\\\\u670824\\\\u65e5\\\\n\\\\u5bd2\\\\u6f6e\\\\u5357\\\\u4e0b\\\\u964d\\\\u6e29\\\\u5f71\\\\u54cd\\\\u6ce2\\\\u53ca\\\\u6c5f\\\\u5357 \\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u6674\\\\u5929\\\\u4e3a\\\\u4e3b\\\\u5b9c\\\\u51fa\\\\u884c\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670824\\\\u65e5\\\\uff09\\\\uff0c\\\\u5bd2\\\\u6f6e\\\\u8fdb\\\\u4e00\\\\u6b65\\\\u5357\\\\u4e0b\\\\uff0c\\\\u6c5f\\\\u5357\\\\u52a0\\\\u5165\\\\u964d\\\\u6e29\\\\u884c\\\\u5217\\\\uff0c\\\\u540c\\\\u65f6\\\\uff0c\\\\u5317\\\\u65b9\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u7ee7\\\\u7eed\\\\u4e0b\\\\u6ed1\\\\uff0c\\\\u4e1c\\\\u5317\\\\u3001\\\\u534e\\\\u5317\\\\u591a\\\\u5730\\\\u5c06\\\\u521b\\\\u4eca\\\\u5e74\\\\u4e0b\\\\u534a\\\\u5e74\\\\u6765\\\\u6c14\\\\u6e29\\\\u65b0\\\\u4f4e\\\\uff0c\\\\u516c\\\\u4f17\\\\u9700\\\\u52a0\\\\u5f3a\\\\u4fdd\\\\u6696\\\\u5de5\\\\u4f5c\\\\u3002\\\\n11\\\\u670823\\\\u65e5\\\\n\\\\u4eca\\\\u51ac\\\\u7b2c\\\\u4e8c\\\\u8f6e\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u4e1c\\\\u79fb\\\\u5357\\\\u4e0b \\\\u534e\\\\u5317\\\\u9ec4\\\\u6dee\\\\u7b49\\\\u5730\\\\u964d\\\\u6e29\\\\u731b\\\\u70c8\\\\n\\\\u4eca\\\\u660e\\\\u5929\\\\uff0811\\\\u670823\\\\u65e5\\\\u81f324\\\\u65e5\\\\uff09\\\\uff0c\\\\u4eca\\\\u51ac\\\\u7b2c\\\\u4e8c\\\\u8f6e\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u5357\\\\u4e0b\\\\uff0c\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u3002\\\\u5176\\\\u4e2d\\\\u4eca\\\\u5929\\\\u4ecd\\\\u662f\\\\u964d\\\\u6e29\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5\\\\u3002\\\\n11\\\\u670822\\\\u65e5\\\\n\\\\u4eca\\\\u8d77\\\\u5bd2\\\\u6f6e\\\\u5f71\\\\u54cd\\\\u8fdb\\\\u5165\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5 \\\\u4e1c\\\\u5317\\\\u5c06\\\\u6709\\\\u5927\\\\u5230\\\\u66b4\\\\u96ea\\\\u6c14\\\\u6e29\\\\u731b\\\\u8dcc\\\\n\\\\u4eca\\\\u8d77\\\\u4e09\\\\u5929\\\\uff0811\\\\u670822\\\\u65e5\\\\u81f324\\\\u65e5\\\\uff09\\\\u5bd2\\\\u6f6e\\\\u7ee7\\\\u7eed\\\\u5411\\\\u4e1c\\\\u6269\\\\u5c55\\\\uff0c\\\\u8fce\\\\u6765\\\\u5927\\\\u98ce\\\\u3001\\\\u964d\\\\u6e29\\\\u5f71\\\\u54cd\\\\u6838\\\\u5fc3\\\\u65f6\\\\u6bb5\\\\uff0c\\\\u9700\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n11\\\\u670821\\\\u65e5\\\\n11\\\\u6708\\\\u7b2c\\\\u4e8c\\\\u573a\\\\u5bd2\\\\u6f6e\\\\u6765\\\\u88ad \\\\u5317\\\\u65b9\\\\u8fce\\\\u5267\\\\u70c8\\\\u964d\\\\u6e29\\\\n\\\\u4eca\\\\u5929\\\\u6211\\\\u56fd\\\\u5927\\\\u90e8\\\\u4ecd\\\\u5ef6\\\\u7eed\\\\u6674\\\\u6717\\\\u5347\\\\u6e29\\\\u6a21\\\\u5f0f\\\\uff0c\\\\u4e0e\\\\u6b64\\\\u540c\\\\u65f6\\\\uff0c\\\\u4eca\\\\u5e7411\\\\u6708\\\\u7b2c\\\\u4e8c\\\\u573a\\\\u5bd2\\\\u6f6e\\\\u5df2\\\\u7ecf\\\\u542f\\\\u7a0b\\\\uff0c\\\\u4eca\\\\u8d77\\\\u81f324\\\\u65e5\\\\u5c06\\\\u81ea\\\\u897f\\\\u5411\\\\u4e1c\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u3002\\\\n11\\\\u670819\\\\u65e5\\\\n\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u6301\\\\u7eed\\\\u5347\\\\u6e29 \\\\u534e\\\\u5317\\\\u7b49\\\\u5730\\\\u96fe\\\\u548c\\\\u973e\\\\u5929\\\\u6c14\\\\u53d1\\\\u5c55\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670819\\\\u65e5\\\\uff09\\\\u81f322\\\\u65e5\\\\uff0c\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5c06\\\\u6301\\\\u7eed\\\\u5347\\\\u6e29\\\\uff0c\\\\u6674\\\\u5929\\\\u4e3a\\\\u4e3b\\\\uff0c\\\\u964d\\\\u6c34\\\\u7a00\\\\u5c11\\\\u300222\\\\u65e5\\\\u524d\\\\u540e\\\\uff0c\\\\u5404\\\\u5730\\\\u6c14\\\\u6e29\\\\u5c06\\\\u8fce\\\\u6765\\\\u8fd1\\\\u671f\\\\u9ad8\\\\u70b9\\\\u3002\\\\n11\\\\u670818\\\\u65e5\\\\n\\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u7ef4\\\\u6301\\\\u6674\\\\u6717\\\\u5e72\\\\u71e5 \\\\u6c14\\\\u6e29\\\\u5c06\\\\u9646\\\\u7eed\\\\u56de\\\\u5347\\\\u81f3\\\\u5e38\\\\u5e74\\\\u540c\\\\u671f\\\\u504f\\\\u9ad8\\\\u72b6\\\\u6001\\\\n\\\\u672a\\\\u6765\\\\u4e09\\\\u5929\\\\uff0811\\\\u670818\\\\u65e5\\\\u81f320\\\\u65e5\\\\uff09\\\\uff0c\\\\u5168\\\\u56fd\\\\u5927\\\\u90e8\\\\u5c06\\\\u7ef4\\\\u6301\\\\u6674\\\\u6717\\\\u5e72\\\\u71e5\\\\u7684\\\\u5929\\\\u6c14\\\\u683c\\\\u5c40\\\\uff0c\\\\u6c14\\\\u6e29\\\\u4e5f\\\\u5c06\\\\u9010\\\\u6e10\\\\u56de\\\\u5347\\\\u3002\\\\n11\\\\u670817\\\\u65e5\\\\n\\\\u4e1c\\\\u5317\\\\u964d\\\\u96ea\\\\u8fdb\\\\u5165\\\\u6700\\\\u5f3a\\\\u65f6\\\\u6bb5\\\\u5c40\\\\u5730\\\\u5c06\\\\u906d\\\\u5927\\\\u66b4\\\\u96ea \\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u7b49\\\\u5730\\\\u964d\\\\u6e29\\\\u6301\\\\u7eed\\\\n\\\\u4eca\\\\u5929\\\\uff0811\\\\u670817\\\\u65e5\\\\uff09\\\\uff0c\\\\u4e1c\\\\u5317\\\\u5927\\\\u8303\\\\u56f4\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u6301\\\\u7eed\\\\uff0c\\\\u9ed1\\\\u9f99\\\\u6c5f\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u3001\\\\u5409\\\\u6797\\\\u4e1c\\\\u90e8\\\\u7b49\\\\u5c40\\\\u5730\\\\u6216\\\\u906d\\\\u9047\\\\u5927\\\\u66b4\\\\u96ea\\\\uff0c\\\\u9700\\\\u8b66\\\\u60d5\\\\u79ef\\\\u96ea\\\\u6210\\\\u707e\\\\u3002\\\\u53d7\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\uff0c\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u7b49\\\\u5730\\\\u6c14\\\\u6e29\\\\u7ee7\\\\u7eed\\\\u4e0b\\\\u964d\\\\u3002\\\\n11\\\\u670816\\\\u65e5\\\\n\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5f71\\\\u54cd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8 \\\\u4e1c\\\\u5317\\\\u5c40\\\\u5730\\\\u6709\\\\u7279\\\\u5927\\\\u66b4\\\\u96ea\\\\n\\\\u4eca\\\\u660e\\\\u5929\\\\uff0811\\\\u670816\\\\u65e5\\\\u81f317\\\\u65e5\\\\uff09\\\\uff0c\\\\u4e1c\\\\u5317\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u964d\\\\u96ea\\\\u8f83\\\\u5f3a\\\\uff0c\\\\u5c40\\\\u5730\\\\u6709\\\\u7279\\\\u5927\\\\u66b4\\\\u96ea\\\\u3002\\\\u540c\\\\u65f6\\\\uff0c\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5357\\\\u4e0b\\\\u5f71\\\\u54cd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5927\\\\u90e8\\\\u5730\\\\u533a\\\\u3002\\\\n11\\\\u670815\\\\u65e5\\\\n\\\\u65b0\\\\u4e00\\\\u8f6e\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u6765\\\\u88ad\\\\u591a\\\\u5730\\\\u6c14\\\\u6e29\\\\u8d77\\\\u4f0f \\\\u4e1c\\\\u5317\\\\u90e8\\\\u5206\\\\u5730\\\\u533a\\\\u5c06\\\\u73b0\\\\u8f83\\\\u5f3a\\\\u964d\\\\u96ea\\\\n\\\\u9884\\\\u8ba1\\\\u4eca\\\\u5929\\\\uff0811\\\\u670815\\\\u65e5\\\\uff09\\\\u8d77\\\\u81f317\\\\u65e5\\\\uff0c\\\\u4e00\\\\u80a1\\\\u4e2d\\\\u7b49\\\\u5f3a\\\\u5ea6\\\\u51b7\\\\u7a7a\\\\u6c14\\\\u5c06\\\\u5f71\\\\u54cd\\\\u6211\\\\u56fd\\\\u4e2d\\\\u4e1c\\\\u90e8\\\\u5730\\\\u533a\\\\uff0c\\\\u4e0d\\\\u4ec5\\\\u5927\\\\u98ce\\\\u964d\\\\u6e29\\\\u5929\\\\u6c14\\\\u4e0d\\\\u4f1a\\\\u7f3a\\\\u5e2d\\\\uff0c\\\\u800c\\\\u4e14\\\\u4e1c\\\\u5317\\\\u5730\\\\u533a\\\\u8fd8\\\\u5c06\\\\u51fa\\\\u73b0\\\\u8f83\\\\u5f3a\\\\u96e8\\\\u96ea\\\\u5929\\\\u6c14\\\\u3002\\\\n\\\\u8054\\\\u64ad\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\n\\\\u66f4\\\\u591a>>\\\\u9ad8\\\\u6e05\\\\u56fe\\\\u96c6\\\\n\\\\u5929\\\\u6c14\\\\u89c6\\\\u9891\\\\n\\\\u536b\\\\u661f\\\\u4e91\\\\u56fe\\\\u770b\\\\u5c71\\\\u4e1c\\\\u201c\\\\u96ea\\\\u7a9d\\\\u201d\\\\u51b7\\\\u6d41\\\\u964d\\\\u96ea\\\\n\\\\u96e8\\\\u96ea\\\\u5306\\\\u5306\\\\u8fc7 \\\\u6d17\\\\u8f66\\\\u6709\\\\u673a\\\\u4f1a\\\\n>> \\\\u751f\\\\u6d3b\\\\u65c5\\\\u6e38\\\\n\\\\u666f\\\\u70b9\\\\u63a8\\\\u8350\\\\n\\\\u6c14\\\\u8c61\\\\u4ea7\\\\u54c1\\\\n\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\n\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\u70ed\\\\u7ebf\\\\n\\\\u62e8\\\\u6253400-6000-121\\\\u8fdb\\\\u884c\\\\u6c14\\\\u8c61\\\\u670d\\\\u52a1\\\\u54a8\\\\u8be2\\\\u3001\\\\u5efa\\\\u8bae\\\\u3001\\\\u5408\\\\u4f5c\\\\u4e0e\\\\u6295\\\\u8bc9\\\\n\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\u7535\\\\u8bdd\\\\u67e5\\\\u8be2\\\\n\\\\u62e8\\\\u625312121\\\\u621696121\\\\u8fdb\\\\u884c\\\\u5929\\\\u6c14\\\\u9884\\\\u62a5\\\\u67e5\\\\u8be2\\\\n\\\\u624b\\\\u673a\\\\u67e5\\\\u8be2\\\\n\\\\u968f\\\\u65f6\\\\u968f\\\\u5730\\\\u901a\\\\u8fc7\\\\u624b\\\\u673a\\\\u767b\\\\u5f55\\\\u4e2d\\\\u56fd\\\\u5929\\\\u6c14WAP\\\\u7248\\\\u67e5\\\\u770b\\\\u5404\\\\u5730\\\\u5929\\\\u6c14\\\\u8d44\\\\u8baf\\\\n\\\\u7f51\\\\u7ad9\\\\u670d\\\\u52a1\\\\n\\\\u5173\\\\u4e8e\\\\u6211\\\\u4eec\\\\u8054\\\\u7cfb\\\\u6211\\\\u4eec\\\\u5e2e\\\\u52a9\\\\u4eba\\\\u5458\\\\u62db\\\\u8058\\\\n\\\\u5ba2\\\\u670d\\\\u4e2d\\\\u5fc3\\\\u7248\\\\u6743\\\\u58f0\\\\u660e\\\\u5f8b\\\\u5e08\\\\u7f51\\\\u7ad9\\\\u5730\\\\u56fe\\\\n\\\\u8425\\\\u9500\\\\u4e2d\\\\u5fc3\\\\n\\\\u5546\\\\u52a1\\\\u5408\\\\u4f5c\\\\u5e7f\\\\u544a\\\\u670d\\\\u52a1\\\\u5a92\\\\u8d44\\\\u5408\\\\u4f5c\\\\n \\\\u53f0\\\\u98ce\\\\u8def\\\\u5f84\\\\n\\\\u7a7a\\\\u95f4\\\\u5929\\\\u6c14\\\\n\\\\u56fe\\\\u7247\\\\n\\\\u4e13\\\\u9898\\\\n\\\\u73af\\\\u5883\\\\n\\\\u65c5\\\\u6e38\\\\n\\\\u751f\\\\u6001\\\\n\\\\u6c14\\\\u8c61\\\\u79d1\\\\u666e\\\\n\\\\u4e00\\\\u5e26\\\\u4e00\\\\u8def\\\\n\\\\u4ea7\\\\u521b\\\\u5e73\\\\u53f0\\\\n\\\\u70ed\\\\u95e8\\\\u57ce\\\\u5e02\\\\n\\\\u70ed\\\\u95e8\\\\u666f\\\\u70b9\\\\n\\\\u9009\\\\u62e9\\\\u7701\\\\u5e02\\\\n<<\\\\u8fd4\\\\u56de\\\\n\\\\u5168\\\\u56fd\\\\n\\\\u5468\\\\u8fb9\\\\u57ce\\\\u5e02\\\\n\\\\u5468\\\\u8fb9\\\\u666f\\\\u70b9\\\\n\\\\u672c\\\\u5730\\\\u4e61\\\\u9547\\\\n\\\\u70ed\\\\u95e8\\\\u57ce\\\\u5e02\\\\n\\\\u9009\\\\u62e9\\\\u6d32\\\\u9645\\\\n28\\\\u65e5\\\\uff08\\\\u4eca\\\\u5929\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n3/-4\\\\u2103\\\\n<3\\\\u7ea7\\\\u8f6c3-4\\\\u7ea7\\\\n29\\\\u65e5\\\\uff08\\\\u660e\\\\u5929\\\\uff09\\\\n\\\\u6674\\\\n3/-5\\\\u2103\\\\n3-4\\\\u7ea7\\\\u8f6c<3\\\\u7ea7\\\\n30\\\\u65e5\\\\uff08\\\\u540e\\\\u5929\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n4/-5\\\\u2103\\\\n<3\\\\u7ea7\\\\n1\\\\u65e5\\\\uff08\\\\u5468\\\\u4e94\\\\uff09\\\\n\\\\u6674\\\\n 6/-4\\\\u2103\\\\n<3\\\\u7ea7\\\\n2\\\\u65e5\\\\uff08\\\\u5468\\\\u516d\\\\uff09\\\\n\\\\u6674\\\\n8/-3\\\\u2103\\\\n<3\\\\u7ea7\\\\n3\\\\u65e5\\\\uff08\\\\u5468\\\\u65e5\\\\uff09\\\\n\\\\u6674\\\\n8/-3\\\\u2103\\\\n<3\\\\u7ea7\\\\n4\\\\u65e5\\\\uff08\\\\u5468\\\\u4e00\\\\uff09\\\\n\\\\u591a\\\\u4e91\\\\n9/-2\\\\u2103\\\\n<3\\\\u7ea7\\\\n\\\\u84dd\\\\u5929\\\\u9884\\\\u62a5\\\\u7efc\\\\u5408\\\\u5929\\\\u6c14\\\\u73b0\\\\u8c61\\\\u3001\\\\u80fd\\\\u89c1\\\\u5ea6\\\\u3001\\\\u7a7a\\\\u6c14\\\\u8d28\\\\u91cf\\\\u7b49\\\\u56e0\\\\u5b50\\\\uff0c\\\\u9884\\\\u6d4b\\\\u672a\\\\u6765\\\\u4e00\\\\u5468\\\\u7684\\\\u5929\\\\u7a7a\\\\u72b6\\\\u51b5\\\\u3002\\\\n\\\\u5f3a\\\\u964d\\\\u6e29\\\\uff0c\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u6781\\\\u6613\\\\u53d1\\\\u751f\\\\u611f\\\\u5192\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u63a8\\\\u8350\\\\u60a8\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u98ce\\\\u529b\\\\u8f83\\\\u5927\\\\uff0c\\\\u6d17\\\\u8f66\\\\u540e\\\\u4f1a\\\\u8499\\\\u4e0a\\\\u7070\\\\u5c18\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u98ce\\\\u529b\\\\u8f83\\\\u5f3a\\\\uff0c\\\\u8bf7\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u98ce\\\\u529b\\\\u8f83\\\\u5927\\\\uff0c\\\\u6d17\\\\u8f66\\\\u540e\\\\u4f1a\\\\u8499\\\\u4e0a\\\\u7070\\\\u5c18\\\\u3002\\\\n \\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u5bd2\\\\u51b7\\\\uff0c\\\\u63a8\\\\u8350\\\\u60a8\\\\u8fdb\\\\u884c\\\\u5ba4\\\\u5185\\\\u8fd0\\\\u52a8\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u7fbd\\\\u7ed2\\\\u670d\\\\u7b49\\\\u9686\\\\u51ac\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\\\\u8f90\\\\u5c04\\\\u8f83\\\\u5f31\\\\uff0c\\\\u6d82\\\\u64e6SPF12-15\\\\u3001PA+\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u5929\\\\u51b7\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u8303\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u68c9\\\\u8863\\\\u52a0\\\\u7f8a\\\\u6bdb\\\\u886b\\\\u7b49\\\\u51ac\\\\u5b63\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n \\\\u6d82\\\\u64e6SPF\\\\u5927\\\\u4e8e15\\\\u3001PA+\\\\u9632\\\\u6652\\\\u62a4\\\\u80a4\\\\u54c1\\\\u3002\\\\n\\\\u6e29\\\\u5dee\\\\u8f83\\\\u5927\\\\uff0c\\\\u8f83\\\\u6613\\\\u611f\\\\u5192\\\\uff0c\\\\u6ce8\\\\u610f\\\\u9632\\\\u62a4\\\\u3002\\\\n\\\\u6c14\\\\u6e29\\\\u8f83\\\\u4f4e\\\\uff0c\\\\u5728\\\\u6237\\\\u5916\\\\u8fd0\\\\u52a8\\\\u8bf7\\\\u6ce8\\\\u610f\\\\u589e\\\\u51cf\\\\u8863\\\\u7269\\\\u3002\\\\n\\\\u65e0\\\\u9700\\\\u62c5\\\\u5fc3\\\\u8fc7\\\\u654f\\\\uff0c\\\\u53ef\\\\u653e\\\\u5fc3\\\\u5916\\\\u51fa\\\\uff0c\\\\u4eab\\\\u53d7\\\\u751f\\\\u6d3b\\\\u3002\\\\n\\\\u5efa\\\\u8bae\\\\u7740\\\\u539a\\\\u5916\\\\u5957\\\\u52a0\\\\u6bdb\\\\u8863\\\\u7b49\\\\u670d\\\\u88c5\\\\u3002\\\\n\\\\u5929\\\\u6c14\\\\u8f83\\\\u597d\\\\uff0c\\\\u9002\\\\u5408\\\\u64e6\\\\u6d17\\\\u6c7d\\\\u8f66\\\\u3002\\\\n\"}]', name='tavily_search_results_json', tool_call_id='tavily_search_results_json:0')]}}\n","----\n","{'agent': {'messages': [AIMessage(content='根据中国天气网的信息，北京的气温比较低，较易感冒，建议增加室内运动。今天天气较好，适合洗车。气温较低，建议穿厚外套加毛衣等服装。风力较大，洗车后可能会蒙上灰尘。紫外线较弱，建议涂擦SPF12-15、PA+的防晒护肤品。天气较冷，建议进行室内运动。无需担心过度闷热，可放心外出，享受生活。建议穿棉服、冬大衣、皮夹克、厚呢外套、呢帽、手套、围脖、厚棉衣等冬季服装。建议涂擦SPF大于15、PA+防晒护肤品。天气较冷，建议加穿厚外套，进行室内运动。天气较好，适合外出，享受生活。建议穿棉服、冬大衣、皮夹克、厚呢外套等冬季服装。', response_metadata={'token_usage': {'completion_tokens': 174, 'prompt_tokens': 8212, 'total_tokens': 8386}, 'model_name': 'moonshot-v1-32k', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-0150c846-0ce3-43d7-b61a-04d25240cf34-0', usage_metadata={'input_tokens': 8212, 'output_tokens': 174, 'total_tokens': 8386})]}}\n","----\n"]}]},{"cell_type":"markdown","source":["## 流式令牌"],"metadata":{"id":"2KKOCt3W7DEJ"}},{"cell_type":"code","source":["async for event in agent_executor.astream_events(\n","{\"messages\": [HumanMessage(content=\"whats the weather in sf?\")]}, version=\"v1\"\n","):\n","  kind = event[\"event\"]\n","  if kind == \"on_chain_start\":\n","    if (event[\"name\"] == \"Agent\"):  # 在创建智能体是可以设置名称`.with_config({\"run_name\": \"Agent\"})`\n","      print(f\"Starting agent: {event['name']} with input: {event['data'].get('input')}\")\n","    elif kind == \"on_chain_end\":\n","      if (event[\"name\"] == \"Agent\"):  # Was assigned when creating the agent with `.with_config({\"run_name\": \"Agent\"})`\n","        print()\n","        print(\"--\")\n","        print(f\"Done agent: {event['name']} with output: {event['data'].get('output')['output']}\")\n","  if kind == \"on_chat_model_stream\":\n","    content = event[\"data\"][\"chunk\"].content\n","    if content:\n","    # 如果模型返回空，说明是需要调用工具，所以只打印不为空的返回\n","      print(content, end=\"|\")\n","  elif kind == \"on_tool_start\":\n","    print(\"--\")\n","    print(f\"Starting tool: {event['name']} with inputs: {event['data'].get('input')}\")\n","  elif kind == \"on_tool_end\":\n","    print(f\"Done tool: {event['name']}\")\n","    print(f\"Tool output was: {event['data'].get('output')}\")\n","    print(\"--\")\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"L8AaArqz7C2U","executionInfo":{"status":"ok","timestamp":1716776404246,"user_tz":-480,"elapsed":5652,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"41eb0757-a0af-4726-d890-6be3abed9a83"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stderr","text":["/usr/local/lib/python3.10/dist-packages/langchain_core/_api/beta_decorator.py:87: LangChainBetaWarning: This API is in beta and may change in the future.\n","  warn_beta(\n"]},{"output_type":"stream","name":"stdout","text":["--\n","Starting tool: tavily_search_results_json with inputs: {'query': 'weather in San Francisco'}\n","Done tool: tavily_search_results_json\n","Tool output was: [{'url': 'https://www.weatherapi.com/', 'content': \"{'location': {'name': 'San Francisco', 'region': 'California', 'country': 'United States of America', 'lat': 37.78, 'lon': -122.42, 'tz_id': 'America/Los_Angeles', 'localtime_epoch': 1716776372, 'localtime': '2024-05-26 19:19'}, 'current': {'last_updated_epoch': 1716776100, 'last_updated': '2024-05-26 19:15', 'temp_c': 15.6, 'temp_f': 60.1, 'is_day': 1, 'condition': {'text': 'Partly cloudy', 'icon': '//cdn.weatherapi.com/weather/64x64/day/116.png', 'code': 1003}, 'wind_mph': 23.0, 'wind_kph': 37.1, 'wind_degree': 280, 'wind_dir': 'W', 'pressure_mb': 1016.0, 'pressure_in': 30.01, 'precip_mm': 0.0, 'precip_in': 0.0, 'humidity': 60, 'cloud': 25, 'feelslike_c': 15.6, 'feelslike_f': 60.1, 'vis_km': 16.0, 'vis_miles': 9.0, 'uv': 4.0, 'gust_mph': 27.5, 'gust_kph': 44.3}}\"}, {'url': 'https://www.weathertab.com/en/c/e/05/united-states/california/san-francisco/', 'content': 'Temperature Forecast Normal. Avg High Temps 55 to 70 °F. Avg Low Temps 45 to 55 °F. Explore comprehensive May 2024 weather forecasts for San Francisco, including daily high and low temperatures, precipitation risks, and monthly temperature trends. Featuring detailed day-by-day forecasts, dynamic graphs of daily rain probabilities, and ...'}]\n","--\n","The| current| weather| in| San| Francisco| is| partly| cloudy| with| a| temperature| of| |60|.|1|°F| (|15|.|6|°C|).| The| wind| is| blowing| at| |37|.|1| km|/h| from| the| west|.| The| humidity| is| at| |60|%| with| a| visibility| of| |16|.|0| km|.|"]}]},{"cell_type":"markdown","source":["# 记忆功能"],"metadata":{"id":"pSLSOaP57apS"}},{"cell_type":"code","source":["from langgraph.checkpoint.sqlite import SqliteSaver\n","memory = SqliteSaver.from_conn_string(\":memory:\")"],"metadata":{"id":"9JEJOI_g7aap"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["agent_executor = chat_agent_executor.create_tool_calling_executor(\n","    model, tools, checkpointer=memory\n",")"],"metadata":{"id":"hhqWrJpI7iTP"},"execution_count":null,"outputs":[]},{"cell_type":"code","source":["config = {\"configurable\": {\"thread_id\": \"abc1234\"}}\n","for chunk in agent_executor.stream(\n","{\"messages\": [HumanMessage(content=\"whats my name?\")]}, config\n","):\n","  print(chunk)\n","  print(\"----\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"1S6oQRmh7ovQ","executionInfo":{"status":"ok","timestamp":1716776651760,"user_tz":-480,"elapsed":1821,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"2e72cf33-5de0-418d-f384-3ed31fe7c095"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'agent': {'messages': [AIMessage(content=\"I don't have access to your personal information, including your name. If there's anything specific you'd like to know or discuss, feel free to ask!\", response_metadata={'token_usage': {'completion_tokens': 33, 'prompt_tokens': 132, 'total_tokens': 165}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-188500e0-5ae1-4172-83e0-e874e3f7fc73-0')]}}\n","----\n"]}]},{"cell_type":"code","source":["for chunk in agent_executor.stream(\n","{\"messages\": [HumanMessage(content=\"whats my name?\")]}, config\n","):\n","  print(chunk)\n","  print(\"----\")"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"K7h4Knzx7si5","executionInfo":{"status":"ok","timestamp":1716776603998,"user_tz":-480,"elapsed":1610,"user":{"displayName":"李辉","userId":"12972001611808140221"}},"outputId":"01264daf-3d1a-4532-d1ef-98e095362df7"},"execution_count":null,"outputs":[{"output_type":"stream","name":"stdout","text":["{'agent': {'messages': [AIMessage(content='Your name is Bob! How can I help you, Bob?', response_metadata={'token_usage': {'completion_tokens': 14, 'prompt_tokens': 154, 'total_tokens': 168}, 'model_name': 'gpt-3.5-turbo', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-dbb8f134-1927-4c97-90aa-2ed4804c74e7-0')]}}\n","----\n"]}]}]}